package logic

import (
	"fmt"
	"limutex/api/internal/types"
	"sync"
)

func Locker() string {
	var counter types.Counter
	var wg sync.WaitGroup
	wg.Add(10)
	for i := 0; i < 10; i++ {
		go func() {
			defer wg.Done()
			for j := 0; j < 100000; j++ {
				counter.Lock()
				counter.Count++
				counter.Unlock()
			}
		}()
	}
	wg.Wait()
	return fmt.Sprintf("%v", counter.Count)
}